package cn.zifangsky.jvm.part1.structure.onstackalloc;

/**
 * 逃逸示例
 *
 * @author zifangsky
 * @date 2020/7/2
 * @since 1.0.0
 */
public class Escape {
    public static User u;

    public static void alloc(){
        u=new User();
        u.id=5;
        u.name="coder";
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        for (int i = 0; i < 100000000; i++) {
            alloc();
        }

        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }

    public static class User{
        public int id=0;
        public String name="";
    }

}
